package com.hs.pre.module.searchsort;

import java.util.Iterator;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.hs.pre.model.ProfileBean;
import com.hs.pre.model.SortBean;
import com.hs.pre.module.data.FjPreCache;
import com.hs.pre.module.perinfo.PerInfoDAO;
import com.hs.pre.module.sort.SortDAO;
import com.hs.pre.page.PageParam;
import com.hs.pre.page.PageUtil;
import com.hs.pre.sys.validate.ParameterDic;


public class SearchSortAction extends org.apache.struts.actions.DispatchAction{
	
	
	
	public  ActionForward catalogList(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		
		String sortIdTem = request.getParameter("sortId");
		if(sortIdTem == null ||! (sortIdTem= sortIdTem.trim()).equals(""))
		{
			SortDAO sortDAO = new SortDAO();
			sortDAO.getSortCatalog(1l);
			PageParam pageParam = new PageParam(request);
			 /**
			  * 默认为15条
			  */
			 pageParam.setPageSize(15);
			 ProfileBean profileBean = (ProfileBean)request.getSession().getAttribute(ParameterDic.USER_BARDIAN);
			 if(profileBean != null)
				 pageParam.setPageSize(profileBean.getViewNum());
			 pageParam.setBasePath("searchSort.do?sortPar=catalogList&sortId="+sortIdTem);
			 
			 PerInfoDAO perInfoDAO = new PerInfoDAO();
			 
			 PageUtil pageUtil = perInfoDAO.getPerInfoList("",pageParam);
		
			 request.setAttribute("pageUtil", pageUtil);
			
		}
			return mapping.findForward("result");
	}
	
	
	
	
	public  ActionForward resultTree(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
//		
//		SortDAO sortDAO = new SortDAO();
//		List list =  sortDAO.getSortSearchChi(1, 1000);
//		Iterator iterator = list.iterator();
//		StringBuffer str = new StringBuffer();
//		while(iterator.hasNext())
//		{
//			SortBean sortBean = (SortBean)iterator.next();
//			
//			str.append(sortBean.getSortId()+",");
//		}
//		str.deleteCharAt(str.length()-1);
//		sortDAO.test(str.toString());
//		System.out.println("__________________:"+str);
//		System.out.println("-----活动文件大小-----------:"+list.size());
		
		FjPreCache fjPreCache = FjPreCache.getInstance();
		System.out.println(fjPreCache.getPreStrId(1413l));
		System.out.println("___k_____TREE_____-:测试成功!!");
		
//		SortDAO sortDAO = new SortDAO();
//		sortDAO.getSortCatalog(1l);
		
		return mapping.findForward("resultTree");
	}
	
}
